 <?php                                                                                              
    $csspath = '';
    $jspath = 'email/email.js';
 ?>
<?php require_once VIEWPATH.'common/header.php'; ?>
<?php require_once VIEWPATH.'common/sidebar.php'; ?>
<!--main content start-->
<section id="main-content">
    <section class="wrapper site-min-height">
        <div class="row mt">
          <div class="col-md-12">
              <div class="content-panel">
                  <table class="table table-striped table-advance table-hover">
                    <h4><i class="fa fa-angle-right"></i>当前视频</h4>
                    <hr>
                    <div style="padding:20px 0 0 0; ">
                        <div class="col-md-6">
                            <div id="myElement">Loading the video...</div>
                        </div>
                        <div class="col-md-6">
                            <div class="col-lg-9 col-md-8 col-sm-12 profile-info">
                            <div class=""><h3><?=$detail['title']?></h3></div>
                            <div class=""><?=$detail['des']?></div><br/>
                            <div class="play_percent" style="color: green">当前学习进度:<?= intval($playdetail['playtime']/$playdetail['duration']*100)?intval($playdetail['playtime']/$playdetail['duration']*100):0?>%</div>
                        </div>
                        </div>
                    </div>
                  </table>
              </div><!-- /content-panel -->
          </div><!-- /col-md-12 -->
      </div><!-- /row -->
  </section>
</section>
<?php require_once VIEWPATH.'common/footer.php'; ?>
<script type="text/javascript" src="<?=STATICURL?>jwplayer/jwplayer.js"></script>
<script type="text/javascript">
  jwplayer.logo="<?=STATICURL?>jwplayer/logo.png";
  jwplayer.url="http://www.baidu.com";
    jwplayer("myElement").setup({
    flashplayer: "<?=STATICURL?>jwplayer/jwplayer.flash.swf",
    image: "<?=STATICURL?>jwplayer/player.jpg",
    file: "<?=$detail['fileAttach']?>",
    skin: "<?=STATICURL?>jwplayer/skin/five.xml", 
    title: 'JmsGG.Com',
    description: "Http://Www.JmsGG.Com/", 
    screencolor: "#fff",   //播放器颜色
    stretching: "fill",    //画面自适应
    //autostart:true,         //自动播放
    //mute: true,           //静音
    width: "100%",
    aspectratio: "16:9",
    events:{
        onPlay:function(){
           // console.log(1);
           // setTimeout(updateDate(this.getPosition()),200); 
        },
        onTime:function(){
            var position = this.getPosition();
            var duration = this.getDuration();
            var completed = this.getState();
            var id = "<?=$detail['id']?>";
            var play_percent = "当前学习进度："+parseInt((position/duration)*100)+"%";
            $(".play_percent").text(play_percent);
            if((position>1 && parseInt(position%10) == 0) || position == duration)
            {
               
                updateDate(id,position,duration);
            }
        },
        onPlaylistComplete:function(){
            var duration = this.getDuration();
            var id = "<?=$detail['id']?>";
            var persient = "当前学习进度：100%";
            $(".play_percent").text(persient);
            updateDate(id,duration,duration);
        }
    }
    });
function updateDate(id,position,duration) 
{ 
    $.post("/video/updateTime?debug=1",{id:id,position:position,duration:duration},function(res){
                });
}
function KeyOn_Space(ev){     //JW Player 空格控制播放暂停 <body onKeyDown="KeyOn_Space(event);">
    ev = ev || window.event;    
    var code = (ev.keyCode || ev.which);   
    if(code == 32) {  
        jwplayer('myElement').pause();  
    }  
}  

</script>